package pri.zxx.learndemo.xmlpaser;

import com.alibaba.fastjson.JSON;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import com.thoughtworks.xstream.annotations.XStreamAliasType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.xml.bind.JAXBException;
import java.math.BigDecimal;

@EqualsAndHashCode(callSuper = true)
//@XStreamAliasType("request")
@Data
@Accessors(chain = true)
public class XmlDto extends AbstractXmlDto {

    @XStreamAlias(value = "inv:VALUE1")
    private String name = "zxx";
    @XStreamAlias(value = "inv:VALUE2")
    private Long number;
    @XStreamAlias(value = "inv:VALUE3")
    private BigDecimal price = BigDecimal.valueOf(100).setScale(4);

    public static void main(String[] args) throws JAXBException, InstantiationException, IllegalAccessException {
        String s = XmlTransfer.objToXmlStream(new XmlDtoExt());
        System.out.println(s);
        XmlDtoExt xmlDtoExt = XmlTransfer.xmlToObjStream(XmlDtoExt.class, s);
        System.out.println(JSON.toJSONString(xmlDtoExt));
    }

}
